﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using YXShop.BLL.Admin;
using System.Collections.Generic;

namespace YXShop.Web.membercenter.shop.shop_info
{
    public partial class shop_paymentmanage_list : System.Web.UI.Page
    {
        YXShop.BLL.Member.MemberAccount memberBll = new YXShop.BLL.Member.MemberAccount();
        YXShop.BLL.SystemInfo.TerraceManage terraceBll = new YXShop.BLL.SystemInfo.TerraceManage();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (ChangeHope.WebPage.PageRequest.GetFormString("Option") != string.Empty && ChangeHope.WebPage.PageRequest.GetFormString("id") != "")
                {
                    string types = Request["Option"].Trim();
                    string id = ChangeHope.WebPage.PageRequest.GetFormString("id");
                    if (types == "del")
                    {
                        terraceBll.Delete(Convert.ToInt32(id));
                    }
                    if (types == "delAll")
                    {
                        terraceBll.DeleteAll(id);
                    }
                    Response.End();
                    return;
                }
                this.litPay.Text = GetList();
            }
        }
        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        public string GetList()
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            ChangeHope.WebPage.Table table = new ChangeHope.WebPage.Table();
            YXShop.BLL.SystemInfo.TerraceManage tmDate = new YXShop.BLL.SystemInfo.TerraceManage();
            ChangeHope.DataBase.DataByPage datePage = tmDate.GetList(" [order by] payment_taxis asc ", 20, " and payment_putoutid=" + Session["MemberID"].ToString());//GetAllList();
            //添加头
            table.AddHeadCol("", "<input id=\"chall\" type=\"checkbox\" onclick=\"SelectAll(chall)\" />全选");
            table.AddHeadCol("", "排序");
            table.AddHeadCol("", "平台名称");
            table.AddHeadCol("", "支付平台");
            table.AddHeadCol("", "商户ID");
            table.AddHeadCol("", "手续费率");
            table.AddHeadCol("", "常规操作");
            table.AddRow();
            //添加内容
            if (datePage.DataReader != null)
            {
                int curpage = ChangeHope.WebPage.PageRequest.GetInt("pageindex");
                if (curpage < 0)
                {
                    curpage = 1;
                }
                int count = 0;
                while (datePage.DataReader.Read())
                {
                    count++;
                    string No = (15 * (curpage - 1) + count).ToString();
                    table.AddCol("<input id=\"cbTm\"  type=\"checkbox\" value=" + datePage.DataReader["payment_id"] + " />");
                    // table.AddCol(datePage.DataReader["payment_taxis"].ToString());
                    table.AddCol(No);
                    table.AddCol(datePage.DataReader["payment_name"].ToString());
                    table.AddCol(PaymentByID(Convert.ToInt32(datePage.DataReader["payment_garden"])));

                    table.AddCol(datePage.DataReader["payment_seller"].ToString());
                    table.AddCol(datePage.DataReader["payment_expenses"].ToString() + "%");
                    string url = YXShop.TemplateAction.Common.UrlStr("shop_paymentmanage_edit", "Payment_ID=" + datePage.DataReader["payment_id"], "membercenter/shop/shop_info/");
                    table.AddCol("<a href='"+url+"'>编辑</a>  <a href=\"#\" onclick='Del(" + datePage.DataReader["payment_id"] + ")'> 删除</a>&nbsp;" + PaymentById(Convert.ToInt32(datePage.DataReader["payment_garden"])));
                    table.AddRow();
                }
            }
            string view = table.GetTable() + datePage.ReceptionToolBar;
            datePage.Dispose();
            datePage = null;
            return view;
        }

        #region 支付平台申请
        private string PaymentById(int id)
        {
            //1,支付宝；2，财付通，3网银，4线下支付
            string str = "";
            switch (id)
            {
                case 1:
                    str = "<a href='../include/paymentapplication/tenpay.aspx'>申请商户</a>";
                    break;
                case 2:
                    str = "";
                    break;
                case 3:
                    str = "";
                    break;
                case 4:
                    str = "";
                    break;
                default:
                    break;
            }
            return str;
        }
        #endregion

        #region 查询支付平台
        protected string PaymentByID(int PayId)
        {
            string str = "";
            switch (PayId)
            {
                case 2:
                    str = "支付宝";
                    break;
                case 1:
                    str = "财付通";
                    break;
                case 3:
                    str = "网银";
                    break;
                case 4:
                    str = "线下付款";
                    break;
                default:
                    str = "线下付款";
                    break;

            }
            return str.ToString();
        }
        #endregion

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// 
        protected void linkSarch_Click(object sender, EventArgs e)
        {
            this.litPay.Text = GetList();   
        }
     
    }
}
